﻿/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2008                    */
/* Created on:     30/07/2013 17:53:53                          */
/*==============================================================*/


if exists (select 1
            from  sysindexes
           where  id    = object_id('FOURNITURE')
            and   name  = 'CONTIENT_FK'
            and   indid > 0
            and   indid < 255)
   drop index FOURNITURE.CONTIENT_FK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('FOURNITURE')
            and   type = 'U')
   drop table FOURNITURE
go

if exists (select 1
            from  sysobjects
           where  id = object_id('STOCK')
            and   type = 'U')
   drop table STOCK
go

if exists (select 1
            from  sysobjects
           where  id = object_id('TBLUSER')
            and   type = 'U')
   drop table TBLUSER
go

/*==============================================================*/
/* Table: FOURNITURE                                            */
/*==============================================================*/
create table FOURNITURE (
   FOURNIID             integer              not null IDENTITY(0, 1),
   STDESIGNATION        varchar(50)          not null,
   DATE                 datetime             null,
   DESTINATAIRE         varchar(100)         null,
   UNITE                varchar(50)          null,
   DIVISION             varchar(50)          null,
   ENTREE               int                  null,
   SORTIE               int                  null,
   constraint PK_FOURNITURE primary key nonclustered (FOURNIID)
)
go

/*==============================================================*/
/* Index: CONTIENT_FK                                           */
/*==============================================================*/
create index CONTIENT_FK on FOURNITURE (
STDESIGNATION ASC
)
go

/*==============================================================*/
/* Table: STOCK                                                 */
/*==============================================================*/
create table STOCK (
   STDESIGNATION        varchar(50)          not null,
   DESCRIPTION          varchar(200)         null,
   PRIXU                decimal              null,
   TYPEDESIGNATION      varchar(100)         null,
   QUANTITE             int                  null,
   constraint PK_STOCK primary key nonclustered (STDESIGNATION)
)
go

/*==============================================================*/
/* Table: TBLUSER                                               */
/*==============================================================*/
create table TBLUSER (
   LOGINNAME            varchar(50)          not null,
   PASSWORD             varchar(50)          null,
   constraint PK_TBLUSER primary key nonclustered (LOGINNAME)
)
go






/*==============================================================*/
/* Utilisateurs par défaut                                              */
/*==============================================================*/

INSERT INTO [gestionstock].[dbo].[TBLUSER]
           ([LOGINNAME]
           ,[PASSWORD])
     VALUES
           ('admin'
           ,'admin')
GO

INSERT INTO [gestionstock].[dbo].[TBLUSER]
           ([LOGINNAME]
           ,[PASSWORD])
     VALUES
           ('sara'
           ,'sara')
GO

INSERT INTO [gestionstock].[dbo].[TBLUSER]
           ([LOGINNAME]
           ,[PASSWORD])
     VALUES
           ('user'
           ,'user')
GO
